﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RollCall.Data
{
    public class MyDbContext : DbContext
    {
        public DbSet<Student> Students { get; set; }
        public DbSet<Answer> Answers { get; set; }
        public DbSet<Group> Groups { get; set; }

        /// <summary>
        /// 配置数据库信息
        /// </summary>
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlite("Data Source=./data/rollcall.db");
        }
    }

    /// <summary>
    /// 答题
    /// </summary>
    public class Answer
    {
        /// <summary>
        /// 主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 学生关联主键
        /// </summary>
        public Guid StudentId { get; set; }

        /// <summary>
        /// 结果， 是否答对
        /// </summary>
        public bool IsRight { get; set; }

        /// <summary>
        /// 回答的题问题学科
        /// </summary>
        public Subject Subject { get; set; }

        /// <summary>
        /// 答题时所在分组
        /// </summary>
        public string Group { get; set; }

        /// <summary>
        /// 创建时间（答题时间)
        /// </summary>
        public DateTime CreationTime { get; set; } = DateTime.Now;
    }

    /// <summary>
    /// 分组
    /// </summary>
    public class Group
    {
        /// <summary>
        /// 主键
        /// </summary>
        public Guid Id { get; set; } = Guid.NewGuid();

        /// <summary>
        /// 分组名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 所属性学科
        /// </summary>
        public Subject Subject { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreationTime { get; set; } = DateTime.Now;
    }


    /// <summary>
    /// 学生
    /// </summary>
    public class Student
    {
        /// <summary>
        /// 主键
        /// </summary>
        public Guid Id { get; set; } = Guid.NewGuid();

        /// <summary>
        /// 分组Id
        /// </summary>
        public Guid GroupId { get; set; }

        /// <summary>
        /// 学生名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreationTime { get; set; } = DateTime.Now;

    }

    /// <summary>
    /// 学科
    /// </summary>
    public enum Subject
    {
        语文,
        数学,
        英语
    }

}
